angular.module('exchange').controller('exchangeListCtrl', ['$scope', '$http', '$timeout', '$uibModal', function ($scope, $http, $timeout, $uibModal) {
    $scope.code = '';
    $scope.flag = false;
    $scope.dataList = [];
    $scope.exchange = function () {
        $scope.flag = true;
        $http.get(ctx + '/exchange/getCode?code=' + $scope.code).then(function (resp) {
            console.log(resp);
            if (resp.data)
                $scope.dataList = resp.data.exchangeList;
            else
                $scope.dataList = [];
        });
    }

    $scope.exchangeTrue = function (voteId, followerId) {
        var r = confirm("确认要兑换码？");
        if (r == true) {
            $http.get(ctx + '/exchange/hasExchange?voteId=' + voteId + '&followerId=' + followerId).then(function (resp) {
                alert('兑换成功');
                $scope.exchange();
            });
        }
    }
}]);